package cn.yh.liu.service.impl;


import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.yh.liu.dao.OrderMapper;
import cn.yh.liu.entity.Order;
import cn.yh.liu.entity.Page;
import cn.yh.liu.service.OrderService;
@Service("orderService")
public class OrderServiceImpl implements OrderService{
	@Autowired
	private OrderMapper orderMapper;
	
	@Override
	public int getAll() {
		// TODO Auto-generated method stub
		return orderMapper.getAll();
	}

	@Override
	public Page<Order> findByPage(Map<String, Object> order) {
		Page<Order> page = new Page<Order>();
		int pageIndex = Integer.parseInt(String.valueOf(order.get("PageIndex")));
		int pageSize = Integer.parseInt(String.valueOf(order.get("PageSize")));	
		page.setPageIndex(pageIndex);
		page.setPageSize(pageSize);
		page.setCount(orderMapper.getAll());
		page.setList(orderMapper.findByPage(order));
		return page;
	}

	@Override
	public void addOrder(Order order) {
		// TODO Auto-generated method stub
		orderMapper.addOrder(order);
	}

	@Override
	public void delById(int id) {
		// TODO Auto-generated method stub
		orderMapper.delById(id);
	}

	@Override
	public void editOrder(Order order) {
		// TODO Auto-generated method stub
		orderMapper.editOrder(order);
	}

	@Override
	public Order findById(int id) {
		return orderMapper.findById(id);
	}

}
